package minJump;

import java.util.ArrayList;
import java.util.Iterator;

public class MyMethodOne {
	int min = Integer.MAX_VALUE;
	public int minJump(int[] jump) {
		ArrayList<Integer> help = new ArrayList<Integer>();
		for(int i=0 ; i<jump.length ; i++)help.add(i);
		helper(0,0,jump,help);
		return min;
    }
	private void helper(int time,int index,int[] jump,ArrayList<Integer> help) {
		if( index>=jump.length ) {
			min = Math.min(min, time);
			return ;
		}
		Iterator<Integer> it = help.iterator();
		while( it.hasNext() ) {
			int tem = it.next();
			if( tem>index )break;
			it.remove();
			helper(time+1,tem,jump,help);
		}
		helper(time+1,index+jump[index],jump,help);		
	}
}
